<template>
  <div class="lists">
    <el-table
      :data="seckListData"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
    >
      <el-table-column prop="id" label="编号" sortable width="180">
      </el-table-column>
      <el-table-column prop="title" label="活动名称" sortable width="180">
      </el-table-column>
      <el-table-column prop="status" label="状态">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status == 1">启用</el-tag>
          <el-tag v-if="scope.row.status == 2" type="danger">禁用</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="editSeckill(scope.row.id)"
            >编辑</el-button
          >
          <el-button type="danger" @click="deleteSeckill(scope.row.id)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getSeckDelete } from "../../../request/api";
export default {
  props: ["dialog", "seckListData"],
  data() {
    return {};
  },
  methods: {
    // 传给父组件
    editSeckill(id) {
      this.$emit("editSeckill", id);
    },
    // 删除秒杀
    deleteSeckill(id) {
      this.$confirm("是否删除该秒杀活动?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      }).then(
        () => {
          getSeckDelete({ id }).then(
            (res) => {
              if (res.data.code == 200) {
                this.$message.success("删除成功");
                // 刷新列表
                this.$emit("refreshList");
              }
            },
            (err) => err
          );
        },
        (err) => err
      );
    },
  },
};
</script>

<style>
</style>